<html>
 <head>
  <link rel="stylesheet" type="text/css" href="../../core/foam.css" />
  <script language="javascript">
    FOAM_BOOT_DIR = '../../core/';
  </script>
  <script language="javascript" src="../../core/bootFOAM.js"></script>
  <title>FOAM Mail</title>
 </head>
 <body>
  <script language="javascript">
    var i = window.location.search.indexOf('user=');
    GLOBAL.user = ( i == -1 ) ? '"Kevin Greer" <kgr@domain.com>' : window.location.search.substring(i+5);

    var ModelDAO = ModelDAO.create(this, StorageDAO.create({ model: Model }));

//    var EMailDAO = [];
    var EMailDAO = IDBDAO.create({model: EMail});

    // Add Caching
    EMailDAO = CachingDAO.create(
      MDAO.create({model: EMail}),
      EMailDAO);

    // This doesn't work, some async weirdness going on
//    EMailDAO = EMailDAO.where(EQ(EMail.TO, user));

    var stack = StackView.create();
    stack.write(document);

    FOAM.browse(EMail);
  </script>
 </body>
</html>
